package com.loong.nnm;

import com.loong.nnm.services.NetconfToolServices;
import com.loong.nnm.utils.XmlBuilderUtils;
import net.juniper.netconf.NetconfSession;
import net.juniper.netconf.XML;
import net.juniper.netconf.XMLBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

public class MyTestForXML {


    @Autowired
    NetconfToolServices services;


    public void printlnStr(Object o) {
        System.out.println("==================================");
        System.out.println(o);
        System.out.println("==================================");
    }

    @Test
    public void testXML() throws ParserConfigurationException {
        XMLBuilder xmlBuilder = new XMLBuilder();
        XML me = xmlBuilder.createNewXML("me");
        me.setAttribute("xmlns", "urn:ccsa:yang:acc-devm");
        XML append = me.append("ntp-servers");
        printlnStr(me);
        printlnStr(append);
    }

    @Test
    public void testMyXMLCoat() throws IOException, SAXException {
        XmlBuilderUtils xmlBuilderUtils = new XmlBuilderUtils();
        XML xml = xmlBuilderUtils.editConfigXMLCoat();


        System.out.println(xml);
    }

    @Test
    public void testXML1() {
        try {
            XMLBuilder xmlBuilder = new XMLBuilder();
            XML xml = xmlBuilder.createNewConfig("hello");
            XML ggggg = xmlBuilder.createNewRPC("ggggg");
            XML newRPC = xmlBuilder.createNewRPC("get", "filter", "eqs");
            System.out.println("=========================================");
            System.out.println(xml);
            System.out.println("=========================================");
            System.out.println("-----------------------------------------");
            System.out.println(newRPC);
            System.out.println("-----------------------------------------");
            System.out.println("-----------------------------------------");
            System.out.println("-----------------------------------------");

            xml.append("key1", "hhh");
            xml.append("key1", "hhh");
            xml.append("key2", "hhh");
            System.out.println(xml.toString());
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }


    }

}
